import {
    AxiosError
} from 'axios';

import * as Const from './../const';

import Response from './../response';

export default (res: AxiosError):Promise<any> => {
    let {
        config,
        response
    } = res;

    if(!response) {
        return Promise.reject(
            Const.networkError
        )
    }

    const {
        status
    } = response || {}

    if(status !== 403) {
        return Promise.reject(
            Const.networkError
        )
    }

    return Response({
        ...response,
        config:config
    })
}